package xyz.kail.demo.websocket.javax.servlet;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 */
@WebServlet(name = "sockJsServlet", urlPatterns = "/ws/hello/info")
public class SockJsServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        resp.setHeader("Access-Control-Allow-Origin", req.getHeader("Origin"));
        resp.setHeader("Access-Control-Allow-Credentials", "true");

        PrintWriter writer = resp.getWriter();
        writer.write("{\"entropy\":-427502348,\"origins\":[\"*:*\"],\"cookie_needed\":false,\"websocket\":false}");
        writer.close();
    }
}
